package com.droid.mvvmlib.utils;

public class SafeUnbox {
    public static int unbox(Integer value) {
        return unbox(value, 0);
    }

    public static int unbox(Integer value, int defValue) {
        return value == null ? defValue : value;
    }

    public static long unbox(Long value) {
        return unbox(value, 0L);
    }

    public static long unbox(Long value, long defValue) {
        return value == null ? 0L : value;
    }

    public static short unbox(Short value) {
        return unbox(value, (short) 0);
    }

    public static short unbox(Short value, short defValue) {
        return value == null ? 0 : (short) value;
    }

    public static byte unbox(Byte value) {
        return unbox(value, (byte) 0);
    }

    public static byte unbox(Byte value, byte defValue) {
        return value == null ? 0 : (byte) value;
    }

    public static char unbox(Character value) {
        return unbox(value, '\u0000');
    }

    public static char unbox(Character value, char defValue) {
        return value == null ? defValue : value;
    }

    public static double unbox(Double value) {
        return unbox(value, 0.0);
    }

    public static double unbox(Double value, double defValue) {
        return value == null ? defValue : value;
    }

    public static float unbox(Float value) {
        return unbox(value, 0f);
    }

    public static float unbox(Float value, float defValue) {
        return value == null ? 0f : value;
    }

    public static boolean unbox(Boolean value) {
        return unbox(value, false);
    }

    public static boolean unbox(Boolean value, boolean defValue) {
        return value == null ? defValue : value;
    }
}
